/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.controller;

import java.util.logging.Level;
import java.util.logging.Logger;
import pkl51.error.EntityException;
import pkl51.model.Blok6AModel;
import pkl51.view.kuesioner.PanelBlok6A;

/**
 *
 * @author FITRI ANDRI ASTUTI
 */
public class Blok6AController {

    private Blok6AModel model;

    public void setModel(Blok6AModel model) {
        this.model = model;
    }

    public void insertBlok6A(PanelBlok6A panelBlok6A) throws EntityException {

        try {

            String B6AR1a = panelBlok6A.getTextFieldB6AR1a().getText();
            String B6AR1b = panelBlok6A.getTextFieldB6AR1b().getText();
            String B6AR2a = panelBlok6A.getTextFieldB6AR2a().getText();
            String B6AR2b = panelBlok6A.getTextFieldB6AR2b().getText();
            String B6AR2c = panelBlok6A.getTextFieldB6AR2c().getText();
            String B6AR2d = panelBlok6A.getTextFieldB6AR2d().getText();
            String B6AR2e = panelBlok6A.getTextFieldB6AR2e().getText();
            String B6AR2f = panelBlok6A.getTextFieldB6AR2f().getText();
            String B6AR2g = panelBlok6A.getTextFieldB6AR2g().getText();
            String B6AR2h = panelBlok6A.getTextFieldB6AR2h().getText();
            String B6AR2i = panelBlok6A.getTextFieldB6AR2i().getText();
            String B6AR2j = panelBlok6A.getTextFieldB6AR2j().getText();
            String B6AR2k = panelBlok6A.getTextFieldB6AR2k().getText();
            String B6AR2l = panelBlok6A.getTextFieldB6AR2l().getText();
            String B6AR2m = panelBlok6A.getTextFieldB6AR2m().getText();
            String B6AR2n = panelBlok6A.getTextFieldB6AR2n().getText();
            String B6AR2o = panelBlok6A.getTextFieldB6AR2o().getText();

            model.setForDB(B6AR1a, B6AR1b, B6AR2a, B6AR2b, B6AR2c, B6AR2d, B6AR2e, B6AR2f, B6AR2g, B6AR2h, B6AR2i, B6AR2j, B6AR2k, B6AR2l, B6AR2m, B6AR2n, B6AR2o);

            model.insertBlok6a();
        } catch (Exception ex) {
            Logger.getLogger(Blok6AController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Gagal save data Blok 6A, Cek kembali Blok 6A");
        }
    }

    public void updateBlok6A(PanelBlok6A panelBlok6A) throws EntityException {
        try {

            String B6AR1a = panelBlok6A.getTextFieldB6AR1a().getText();
            String B6AR1b = panelBlok6A.getTextFieldB6AR1b().getText();
            String B6AR2a = panelBlok6A.getTextFieldB6AR2a().getText();
            String B6AR2b = panelBlok6A.getTextFieldB6AR2b().getText();
            String B6AR2c = panelBlok6A.getTextFieldB6AR2c().getText();
            String B6AR2d = panelBlok6A.getTextFieldB6AR2d().getText();
            String B6AR2e = panelBlok6A.getTextFieldB6AR2e().getText();
            String B6AR2f = panelBlok6A.getTextFieldB6AR2f().getText();
            String B6AR2g = panelBlok6A.getTextFieldB6AR2g().getText();
            String B6AR2h = panelBlok6A.getTextFieldB6AR2h().getText();
            String B6AR2i = panelBlok6A.getTextFieldB6AR2i().getText();
            String B6AR2j = panelBlok6A.getTextFieldB6AR2j().getText();
            String B6AR2k = panelBlok6A.getTextFieldB6AR2k().getText();
            String B6AR2l = panelBlok6A.getTextFieldB6AR2l().getText();
            String B6AR2m = panelBlok6A.getTextFieldB6AR2m().getText();
            String B6AR2n = panelBlok6A.getTextFieldB6AR2n().getText();
            String B6AR2o = panelBlok6A.getTextFieldB6AR2o().getText();

            model.setForDB(B6AR1a, B6AR1b, B6AR2a, B6AR2b, B6AR2c, B6AR2d, B6AR2e, B6AR2f, B6AR2g, B6AR2h, B6AR2i, B6AR2j, B6AR2k, B6AR2l, B6AR2m, B6AR2n, B6AR2o);

            model.updateBlok6a();
        } catch (EntityException ex) {

            Logger.getLogger(Blok6AController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Gagal update data Blok 6A. Cek kembali Blok 6A");
        }
    }

    public void getBlok6A(PanelBlok6A panelBlok6A) throws EntityException {
        try {
            model.getBlok6a();

            panelBlok6A.getTextFieldB6AR1a().setText(model.getB6AR1a());
            panelBlok6A.getTextFieldB6AR1b().setText(model.getB6AR1b());
            panelBlok6A.getTextFieldB6AR2a().setText(model.getB6AR2a());
            panelBlok6A.getTextFieldB6AR2b().setText(model.getB6AR2b());
            panelBlok6A.getTextFieldB6AR2c().setText(model.getB6AR2c());
            panelBlok6A.getTextFieldB6AR2d().setText(model.getB6AR2d());
            panelBlok6A.getTextFieldB6AR2e().setText(model.getB6AR2e());
            panelBlok6A.getTextFieldB6AR2f().setText(model.getB6AR2f());
            panelBlok6A.getTextFieldB6AR2g().setText(model.getB6AR2g());
            panelBlok6A.getTextFieldB6AR2h().setText(model.getB6AR2h());
            panelBlok6A.getTextFieldB6AR2i().setText(model.getB6AR2i());
            panelBlok6A.getTextFieldB6AR2j().setText(model.getB6AR2j());
            panelBlok6A.getTextFieldB6AR2k().setText(model.getB6AR2k());
            panelBlok6A.getTextFieldB6AR2l().setText(model.getB6AR2l());
            panelBlok6A.getTextFieldB6AR2m().setText(model.getB6AR2m());
            panelBlok6A.getTextFieldB6AR2n().setText(model.getB6AR2n());
            panelBlok6A.getTextFieldB6AR2o().setText(model.getB6AR2o());
        } catch (Exception ex) {

            Logger.getLogger(Blok6AController.class.getName()).log(Level.SEVERE, null, ex);
            throw new EntityException("Data gagal diload");
        }
    }
    
}
